package trabajoISW2.tests;

import org.junit.Before;
import org.junit.Test;

import trabajoISW2.domain.contracts.IDetail;
import trabajoISW2.domain.exceptions.NoPositiveNumberException;
import trabajoISW2.domain.exceptions.WrongIdException;
import trabajoISW2.domain.implementations.Book;
import trabajoISW2.domain.implementations.Cart;



public class DetailTestSuite {
	
	IDetail d;
	Book b;
	Cart c;
	SuperTest st;
	
	@Before
	public void setup(){
		st = new SuperTest();
		st.inicializa();
		d = st.detail1;
		b = st.book1;
		c = st.cart1;
	}
	
	
	//Tests setItemId
		
	@Test
	public void testSetItemId(){
		d.setDetailId(0);
		d.setDetailId(1);
		d.setDetailId(Integer.MAX_VALUE);
		d.setDetailId(Integer.MAX_VALUE-1);
	}
	
	@Test(expected = WrongIdException.class)
	public void testSetItemId1(){
		d.setDetailId(-1);
	}
	
	//Tests setQuantity
	
	@Test
	public void testSetQuantity(){
		d.setQuantity(1);
		d.setQuantity(99);
		d.setQuantity(98);
	}
	
	@Test(expected = NoPositiveNumberException.class)
	public void testSetQuantity1(){
		d.setQuantity(0);
	}
	
	@Test(expected = NoPositiveNumberException.class)
	public void testSetQuantity2(){
		d.setQuantity(-1);
	}
	
	//Tests setBook
	
	@Test
	public void testSetBook(){
		d.setBook(b);
	}
	
	@Test(expected = IllegalArgumentException.class)
	public void testSetBook1(){
		d.setBook(null);
	}
	


}
